<html>
<head>
    <title>Open 20 questions</title>

    <link href="css/site.css" rel="stylesheet" type="text/css" />

    <link rel="stylesheet/less" type="text/css" href="css/less/style.less" />
    <script src="lib/plugins/less-1.6.0.min.js" type="text/javascript"></script>

</head>

<body>

<div class="wrapper home_page">

    <div class="newgame">
        <a href="/game/">New game</a>
    </div>
    <div class="clear"></div>

    <h3>Recent games</h3>

    <div id="recent_games">
        <div class="records">
            <div class="header">
                <div class="column1">#</div>
                <div class="column2">Played object</div>
                <div class="column3">Guessed object</div>
                <div class="column4">Guess rank</div>
                <div class="column5">Certainty percentage</div>
                <div class="column6">Times played</div>
                <div class="clear"></div>
            </div>
            <div class="clear"></div>

            <?php

            $objectList = RecentGames::GetRecentGames();

            for ($i = 0; $i < count($objectList); ++$i)
            {
                $item = $objectList[$i];

                echo
                    '<div class="record">'.
                    '<div class="column1">'.
                    HTMLHelpers::ToStringLiteral(($i + 1)).
                    '</div>'.

                    '<div class="column2">'.
                    HTMLHelpers::ToStringLiteral($item['PlayedObject']).
                    '</div>'.

                    '<div class="column3">'.
                    HTMLHelpers::ToStringLiteral($item['GuessedObject']).
                    '</div>'.

                    '<div class="column4">'.
                    (HTMLHelpers::ToStringLiteral($item['GuessedRank']) == -1 ? '<span style="font-weight: bold;">New object</span>' : HTMLHelpers::ToStringLiteral($item['GuessedRank'])).
                    '</div>'.

                    '<div class="column5">'.
                    HTMLHelpers::ToStringLiteral($item['CertaintyPercentage']).
                    '</div>'.

                    '<div class="column6">'.
                    HTMLHelpers::ToStringLiteral($item['TimesPlayed']).
                    '</div>'.

                    '<div class="clear"></div>'.
                    '</div>';
            }
            ?>
        </div>
        <div class="clear"></div>

    </div>
    <div class="clear"></div>

    <p>Games in progress: <?php echo Statistics::GetGamesInProgress(); ?></p>

    <p>Games played today: -</p>

    <?php
    $result = Statistics::GetAllStats();
    ?>

    <h3>Stats</h3>

    <div id="stats">
        <div class="records" style="margin-bottom: 0">
            <div class="header">
                <div class="column1"><?php echo $result[0]["StatName"]; ?></div>
                <div class="column2"><?php echo $result[1]["StatName"]; ?></div>
                <div class="column3"><?php echo $result[2]["StatName"]; ?></div>
                <div class="column4"><?php echo $result[3]["StatName"]; ?></div>
                <div class="column5"><?php echo $result[4]["StatName"]; ?></div>
                <div class="clear"></div>
            </div>
            <div class="clear"></div>

            <div class="record">
                <div class="column1"><?php echo number_format($result[0]["StatValue"], 0); ?></div>
                <div class="column2"><?php echo number_format($result[1]["StatValue"], 0); ?></div>
                <div class="column3"><?php echo number_format($result[2]["StatValue"], 0); ?></div>
                <div class="column4"><?php echo number_format($result[3]["StatValue"] * 100 / $result[2]["StatValue"], 2); ?> %</div>
                <div class="column5"><?php echo number_format($result[4]["StatValue"] * 100 / $result[2]["StatValue"], 2); ?> %</div>

                <div class="clear"></div>
            </div>
            <div class="clear"></div>
        </div>
        <div class="clear"></div>

        <div class="records" style="margin-top: 0">
            <div class="header">
                <div class="column1"><?php echo $result[5]["StatName"]; ?></div>
                <div class="column2"><?php echo $result[6]["StatName"]; ?></div>
                <div class="column3"><?php echo $result[7]["StatName"]; ?></div>
                <div class="column4"><?php echo $result[8]["StatName"]; ?></div>
                <div class="column5"><?php echo $result[9]["StatName"]; ?></div>
                <div class="clear"></div>
            </div>
            <div class="clear"></div>

            <div class="record">
                <div class="column1"><?php echo number_format($result[5]["StatValue"] * 100 / $result[2]["StatValue"], 2); ?> %</div>
                <div class="column2"><?php echo number_format($result[6]["StatValue"] * 100 / $result[2]["StatValue"], 2); ?> %</div>
                <div class="column3"><?php echo number_format($result[7]["StatValue"] * 100 / $result[2]["StatValue"], 2); ?> %</div>
                <div class="column4"><?php echo number_format($result[8]["StatValue"] * 100 / $result[2]["StatValue"], 2); ?> %</div>
                <div class="column5"><?php echo number_format($result[9]["StatValue"], 2); ?> %</div>
                <div class="clear"></div>
            </div>
            <div class="clear"></div>
        </div>
        <div class="clear"></div>

    </div>

    <p>Dropped games: <?php echo number_format($result[11]["StatValue"], 0); ?></p>
</div>
<div class="clear"></div>

</body>
</html>
